package com.wk.springboot.dispatch;

import com.wk.springboot.entity.LocalMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class MessageDispatcher {
    @Autowired
    private Map<String, MessageSender> senderMap;
    
    public boolean dispatch(LocalMessage message) {
        MessageSender sender = senderMap.get(message.getEndpointType().toLowerCase() + "Sender");
        return sender.send(message);
    }
}